<template>
  <div id="index">
    <dv-full-screen-container class="bg">
      <dv-loading v-if="loading">Loading...</dv-loading>
      <div v-else class="host-body">
        <div class="d-flex jc-center">
          <dv-decoration-10 style="width:33.3%;height:.0625rem;"/>
          <div class="d-flex jc-center">
            <dv-decoration-8 :color="['#49d2f1']" style="width:1.5rem;height:1rem;"/>
            <div class="title">
              <dv-decoration-11 style="height:1rem;font-weight: 700;font-size: 24px; color: #FFF">智能实验室大屏</dv-decoration-11>
              <dv-decoration-6
                  class="title-bototm"
                  :reverse="true"
                  :color="['#50e3c2', '#67a1e5']"
                  style="width:3.125rem;height:.1rem;"
              />
            </div>
            <dv-decoration-8
                :reverse="true"
                :color="['#568aea']"
                style="width:1.5rem;height:1rem;"
            />
          </div>
          <dv-decoration-10 style="width:33.3%;height:.0625rem; transform: rotateY(180deg);"></dv-decoration-10>
        </div>

        <!-- 第二行 -->
        <div class="d-flex jc-between px-2">
          <div class="d-flex" style="width: 70%">

          </div>
          <div style="width: 23%; height: .0625rem" class="d-flex">
            <div
                class="react-left mr-4"
                style=""
            >
              <span class="react-after"></span>
              <span class="text">{{ dateYear }} {{ dateWeek }} {{ dateDay }}</span>
<!--              <span @click="nexts">下一行  {{ status }}</span>-->
            </div>
          </div>
        </div>

        <div class="body-box">
          <!-- 第三行数据 -->
<!--          <dv-border-box-2>-->
            <PageOne v-if="status == 1"></PageOne>
            <PageTwo v-if="status == 2"></PageTwo>
            <PageThree v-if="status == 3"></PageThree>
            <PageFour v-if="status == 4"></PageFour>
            <PageFive v-if="status == 5"></PageFive>
            <PageSix v-if="status == 6"></PageSix>
<!--          </dv-border-box-2>-->
        </div>
      </div>
    </dv-full-screen-container>
  </div>
</template>

<script>
import {formatTime} from '../utils/index.js'
import PageOne from './pageOne'
import PageTwo from './pageTwo'
import PageThree from './pageThree'
import PageFour from './pageFour'
import PageFive from './pageFive'
import PageSix from './pageSix'

export default {
  data() {
    return {
      loading: true,
      dateDay: null,
      dateYear: null,
      dateWeek: null,
      weekday: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
      status: 1,
      count: 1
    };
  },
  components: {
    PageOne,
    PageTwo,
    PageThree,
    PageFour,
    PageFive,
    PageSix
  },
  mounted() {
    this.timeFn();
    this.cancelLoading();
    window.setInterval(() => {
      if (this.count % 6 == 0) {
        this.status = 6
      } else {
        this.status = this.count % 6
      }
      this.count++
      console.log(this.status, 'statusstatusstatus')
    }, 5000);
    this.getDictSetting()
  },
  methods: {
    nexts(){
        if (this.count % 6 == 0) {
          this.status = 6
        } else {
          this.status = this.count % 6
        }
        this.count++
    },
    timeFn() {
      setInterval(() => {
        this.dateDay = formatTime(new Date(), 'HH: mm: ss');
        this.dateYear = formatTime(new Date(), 'yyyy-MM-dd');
        this.dateWeek = this.weekday[new Date().getDay()];
      }, 1000)
    },
    cancelLoading() {
      setTimeout(() => {
        this.loading = false;
      }, 500);
    },
    /**
     * 获取大屏数据配置
     */
    getDictSetting(){

      let settings = localStorage.getItem("dict");
      if (!settings) {
        this.$http.post(this.urlInterface.getBigDataSetting).then(res => {
          if (res.data.code == 1) {
            console.log(res.data.data, 'res.data.data');
            localStorage.setItem("dict", JSON.stringify(res.data.data))
            console.log(1111)
          } else {
            alert("出错了")
          }
        })
      }
    }
  }
};
</script>

<style lang="scss">
@import '../assets/scss/index.scss';

.body-box {
  //background-color: red;
  height: 11.3rem !important;
  margin-top: .75rem;
}

.content-box {
  width: 100%;
  height: 100%;
}

.two {
  width: 100%;
  height: 100%;
}
</style>
